package com.nenglai.admin.modular.system.util;

import org.apache.commons.lang3.RandomUtils;
import org.springframework.util.DigestUtils;

/**
 * @author kongdehui
 * @date 2021/04/20 22:10
 **/
public class AdminUtil {

    /**
     * 
     * @author kongdehui
     * @date 2021/04/20 22:18
     * @return int 
     */
    public static Integer generateSalt() {
        return RandomUtils.nextInt(100000, 999999);
    }

    /**
     * 
     * @author kongdehui
     * @date 2021/04/20 22:18
     * @param password 
     * @param salt 
     * @return java.lang.String 
     */
    public static String generatePassword(String password, String salt) {
        return DigestUtils.md5DigestAsHex((password + salt).getBytes());
    }

    /**
     * 
     * @author kongdehui
     * @date 2021/04/20 22:19
     * @return java.lang.String 
     */
    public static String generateAvatar() {
        int number = RandomUtils.nextInt(1, 13);
        return "/avatars/" + String.format("%02d", number) + ".png";
    }
}
